<h2>Danh sách hoá đơn</h2>
<table class="tb_table" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="tb_head">
	<td>Thứ tự</td>
	<td>Tên Khách Hàng</td>
	<td>Cá Nhân/Cty</td>
    <td>Tên Cty</td>
    <td>Mã số thuế</td>
	<td>Phương thức thanh toán</td>
	<td>Ngày tạo</td>
	<td>Danh sách đơn hàng</td>
	<td>Trạng thái</td>
	<td>Giá trị hoá đơn</td>
	<td>Thao tác</td>
  </tr>
	<?php 
		$cnt = 0;
		foreach ($invoices as $invoice) 
		{
			$cnt ++;
	?>
  		<tr class="tb_content">
			<td><?php echo $cnt ?></td>
			<td><?php
					$user = new User();
					$user->select($invoice->getuser_id());
					echo "<a href='?act=member_edit&id=".$user->getid()."'>".$user->getname()."</a>";
				?>
			</td>
			<td><?php echo ($invoice->gettype() == 'INDIVIDUAL')? 'Cá Nhân' : (($invoice->gettype() == 'COMPANY') ? 'Công Ty' : '') ?></td>
			<td><?php echo $invoice->getcompany_name() ?></td>
			<td><?php echo $invoice->gettax_code() ?></td>
			<td><?php switch ($invoice->getpayment_method()) {
							case 'NULL': echo '';break;
							case 'CREDIT_CARD': echo 'Thẻ tín dụng';break;
							case 'TRANSFER': echo 'Chuyển khoản';break;
							case 'CASH': echo 'Tiền mặt';break;
						}
			?></td>
			<td><?php echo $invoice->getcreated_at() ?></td>
			<td><a href="?act=orders_manager&invoice_id=<?php echo $invoice->getid() ?>"><img src="images/edit.gif"></a></td>
			<td><?php switch ($invoice->getstatus()) {
							case 'CREATE': echo 'Khởi tạo';break;
							case 'PENDING': echo 'Đang sử lý';break;
							case 'APPROVE': echo 'Xác nhận';break;
							case 'COMPLETE': echo 'Hoàn tất';break;
							case 'CANCEL': echo 'Huỷ bỏ';break;
						}
			?></td>
			<td><?php
				$amount = $invoice->getAmount();
				echo $amount['value'].' '.$amount['currency'];
			?></td>
			<td><a href="?act=edit_invoice&invoice_id=<?php echo $invoice->getid() ?>">Sửa</a></td>
  		</tr>
	<?php } ?>
</table>